package supershop.controller;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import supershop.dao.ICategoryDao;
import supershop.model.Category;


@Controller
@RequestMapping("/admin/start/category")
public class CategoryController {

	@Resource
	private ICategoryDao categoryDao;
	@RequestMapping("/findAll.do")
	@ResponseBody
	public Map findAll(){
		Map<String,Object> map = new HashMap<String, Object>();
		
		List<Category> list =  categoryDao.findAll();
		map.put("code", 0);
		map.put("count", list.size());
		map.put("data", list);
		return map;
	}
	
	//删除
	@RequestMapping("/del.do")
	@ResponseBody
	public int del(int id) {
		return categoryDao.del(id);
	}
	
	//添加
	@RequestMapping("/add.do")
	@ResponseBody
	public int add(Category c) {
		return categoryDao.add(c);
	}
}
